home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
et
/
et3_0-a1.lha
/
et3
/
src
/
PictureItem.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-05
|
1KB
|
78 lines
#ifdef __GNUG__
#pragma implementation
#endif
#include "PictureItem.h"
#include "Class.h"
#include "Picture.h"
//---- PictureItem -------------------------------------------------------------
NewMetaImpl(PictureItem,VObject, (TP(pic), T(base), TB(deletePicture)));
PictureItem::PictureItem(Picture *b, int bs, bool freeold)
{
deletePicture= freeold;
base= bs;
pic= b;
}
PictureItem::PictureItem(int id, Picture *b, int bs, bool freeold) : VObject(id)
{
deletePicture= freeold;
base= bs;
pic= b;
}
PictureItem::~PictureItem()
{
if (deletePicture)
SafeDelete(pic);
}
void PictureItem::SetPicture(Picture *p, bool redraw)
{
if (deletePicture && pic)
delete pic;
deletePicture= FALSE;
pic= p;
SetContentRect(Rectangle(GetOrigin(), GetMinSize().extent), redraw);
}
Metric PictureItem::GetMinSize()
{
if (pic)
return Metric(pic->Size(), base ? base : pic->Size().y);
return VObject::GetMinSize();
}
void PictureItem::Draw(Rectangle r)
{
GrEraseRect(r);
if (pic)
GrShowPicture(contentRect, pic);
}
void PictureItem::DoObserve(int, int part, void*, Object *op)
{
if (op == pic && part != cPartSenderDied)
ForceRedraw();
}
OStream& PictureItem::PrintOn (OStream &s)
{
VObject::PrintOn(s);
return s << pic SP << base SP;
}
IStream& PictureItem::ReadFrom(IStream &s)
{
if (deletePicture)
SafeDelete(pic);
deletePicture= TRUE;
VObject::ReadFrom(s);
return s >> pic >> base;
}